﻿using System.Collections.Generic;
using System.Linq;
using JuCheap.Service.Data;
using JuCheap.Service.Model;
using JuCheap.Service.Extentions;

namespace JuCheap.Service.AppService
{
    public class UserService : IUserService
    {
        public int Add(User user)
        {
            using (var db = new JuCheapDbContext())
            {
                db.Useres.Add(user);

                return db.SaveChanges();
            }
        }

        public List<User> Query(QueryFilter[] filter)
        {
            using (var db = new JuCheapDbContext())
            {
                return db.Useres.AsQueryable().Where(filter).ToList();
            }
        }
    }
}
